﻿using System;
using System.ServiceModel;

using WSU.Cheka.Session.Contracts;

namespace WSU.Cheka.Session.SvcHost
{
    /// <summary>
    /// default instance mode is "PerSession"
    /// </summary>
    public class CalculateSvc : ICalculator
    {
        private float[] m_results = new float[4];

        public CalculateSvc()
        {
            Console.WriteLine("******** New service instance created,session id=<{0}>", OperationContext.Current.SessionId);
        }

        public void Calculate(float x, float y)
        {
            m_results[0] = x + y;
            m_results[1] = x - y;
            m_results[2] = x * y;
            m_results[3] = x / y;
            Console.WriteLine("[calculate] session id=<{0}>", OperationContext.Current.SessionId);
        }

        public float[] GetResults()
        {
            Console.WriteLine("[getresults] session id=<{0}>", OperationContext.Current.SessionId);
            return m_results;
        }
    }
}
